package com.fancy.learncenter.ui.view;

import android.app.Activity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.fancy.learncenter.R;
import com.fancy.learncenter.ui.callback.AddClassPopuImpl;

/**
 * Created by shiweiwei on 2018/1/5.
 */

public class SelectGenderPopu extends BasePopupWindow {

    private Activity mContext;
    private ViewGroup layoutView;
    private View rootView;

    TextView woman;

    TextView man;
    TextView contentTv;


    public SelectGenderPopu(Activity mContext, ViewGroup layoutView, TextView contentTv) {
        super(mContext);
        this.mContext = mContext;
        this.layoutView = layoutView;
        this.contentTv = contentTv;
        initView();

    }

    private void initView() {

        rootView = LayoutInflater.from(mContext).inflate(R.layout.popu_select_gender, null);
        woman = rootView.findViewById(R.id.woman);

        man = rootView.findViewById(R.id.man);

        setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
        setFocusable(true); //安卓中PopupWindow中的EditText无法弹出软键盘解决
        setContentView(rootView);


        rootView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        woman.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                contentTv.setText("女");
                dismiss();
            }
        });

        man.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                contentTv.setText("男");
                dismiss();

            }
        });

    }


    @Override
    public void showPopupWindow() {
        super.showPopupWindow();

        showAtLocation(layoutView, Gravity.CENTER, 0, 0);
    }


}
